home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6307 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: nntp.teleport.com!usenet
  2. From: GHouck <hksys@teleport.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP: Illegal Pointer Arithmetic
  5. Date: 23 Feb 1996 21:37:01 GMT
  6. Organization: systems hk
  7. Message-ID: <4glc1t$ovu@maureen.teleport.com>
  8. References: <4gj0ug$730@news.one.net>
  9. NNTP-Posting-Host: ip-pdx04-40.teleport.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
  14.  
  15. Oren Levin <oren@one.net> wrote:
  16. >I was wondering if someone could help me. I'm in the midst of learning
  17. >C/C++ and am trying to program the examples in Andrew Birnstock and John
  18. >Rex's book "Practical Algorithyms for Programers." I am using Symentec's
  19. >Think C++ (v 6 - Mac).
  20. >The following code is giving me a "illegal pointer arithmetic" error.
  21. >I'm trying to strip the carrage return off of a line of text read from a
  22. >file.
  23. >
  24. >TIA for the help.
  25. >Oren Levin
  26. >oren@one.net
  27. >
  28. >=== code snippet ===
  29. >        while (! feof (fin))
  30. >        {
  31. >            /* read a record */
  32. >            if (fgets (buffer, 127, fin) == NULL)
  33. >                break;
  34. >            
  35. >            /* get rid of the trailing carrage return */
  36. >            buffer [strlen (buffer) - 1] = "\0";
  37. Oren,
  38. Instead of assigning "\0" as your trailing NULL, you should be
  39. assigning a single character: '\0'.
  40. Yours, Geoff Houck
  41.  
  42.  
  43.